package com.wiz.web.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.wiz.web.dao.mapper.FuellingMapper;
import com.wiz.web.dao.mapper.SyncMapper;
import com.wiz.web.service.FuellingService;
import com.wiz.web.service.SyncService;
import com.wiz.web.vo.AdminLoginInfoVO;
import com.wiz.web.vo.ConfigVO;
import com.wiz.web.vo.criteria.AdminCriteria;
import com.wiz.web.vo.criteria.HqStationCriteria;
import com.wiz.web.vo.to.AdminTO;
import com.wiz.web.vo.to.PageTO;
import com.wiz.web.vo.to.StationTO;

@SuppressWarnings("all")  
@Service("syncService")
public class SyncServiceImpl extends BasicServiceImpl implements SyncService {
	private transient final Logger log = LoggerFactory.getLogger(getClass());
	
	@Resource
	private SyncMapper syncMapper;
	@Resource
	private FuellingMapper fuellingMapper;
	@Resource
	private FuellingService fuellingService;

	@Override
	public String syncStationDetail(HqStationCriteria criteria) throws Exception{
		StationTO to = syncMapper.syncStationDetail(criteria.getStationId(), criteria.getUpdateTime());
		return returnResult(CODE_OK, STRING_OK, to);
	}

	@Override
	public String syncAdminClientPermission(AdminCriteria criteria) {
		List<AdminTO> list = syncMapper.syncAdminClientPermission(criteria.getStationId(), criteria.getUpdateTime());
		PageTO page = new PageTO();
		page.setDataList(list);
		return returnResult(CODE_OK, STRING_OK,page);
	}

	@Override
	public String syncAdminLoginInfo(AdminCriteria criteria) {
		AdminLoginInfoVO vo = new AdminLoginInfoVO();
		vo.setAdminCardList(syncMapper.syncAdminCard(criteria.getStationId(), criteria.getUpdateTime()));
		vo.setAdminLoginInfoList(syncMapper.syncAdminLoginInfo(criteria.getStationId(), criteria.getUpdateTime()));
		return returnResult(CODE_OK, STRING_OK,vo);
	}

	@Override
	public String syncConfig(HqStationCriteria criteria) {
		ConfigVO vo = new ConfigVO();
		vo.setPaidTypeConfigList(syncMapper.syncPayTypeConfig(criteria.getHqId(), criteria.getUpdateTime()));
		vo.setPrConfigList(syncMapper.syncPrConfig(criteria.getHqId(), criteria.getUpdateTime()));
		return returnResult(CODE_OK, STRING_OK,vo);
	}
}

